﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for Register
/// </summary>
public class Register
{
	ForumDataContext dc;
    public Register(ForumDataContext d1)
	{
        dc = d1;
	}

    public bool registerNewUser(string userName, string password)
    {
        if (userName.Length < 4 || password.Length < 4) return false;

        var p1 = from p in dc.Uzytkownicies where p.nick == userName select p;
        foreach (var rec1 in p1) return false;

        Uzytkownicy nowyU = new Uzytkownicy
        {
            nick = userName,
            haslo = password
        };
        dc.Uzytkownicies.InsertOnSubmit(nowyU);
        dc.SubmitChanges();

        return true;
    }
}